import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  // 引用使用less的库要配置一下
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  },
  esbuild: {
    target: 'es2015'
  },
  build: {
    transpile: [],
    lib: {
      entry: './packages/index.js',
      name: 'wattpc-ui'
    },
    rollupOptions: {
      external: [
        'vue',
        'ant-design-vue',
        '@wattjs/tool',
        '@wattjs/network',
        '@wattjs/peach',
        'vue3-lazyload',
        'jsoneditor/dist/jsoneditor-minimalist.min',
        'jsoneditor/dist/jsoneditor.min.css',
        '@jsdawn/vue3-tinymce'
      ],
      output: {
        exports: 'named',
        globals: {
          'vue': 'Vue',
          '@wattjs/tool': '@wattjs/tool',
          '@wattjs/network': '@wattjs/network',
          '@wattjs/peach': '@wattjs/peach',
          'vue3-lazyload': 'VueLazyLoad',
          '@jsdawn/vue3-tinymce': 'Vue3Tinymce',
          'jsoneditor/dist/jsoneditor-minimalist.min': 'JSONEditor'
        }
      }
    }
  }
})
